package org.six.ways.spring.user;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

/**
 * @author Mr.Fu
 * @description user service
 * @date 2021/8/14 下午9:00
 */
@Service
@Lazy(value = true)
public class UserService implements DisposableBean {

    public UserService() {
        System.out.println("Bean实例化.");
    }

    public UserService(String name) {
        System.out.println("执行了UserService的构造方法 -> " + name);
    }

    private String name;

    public String getName() {
        if (name == null) {
            return "what's your name.";
        }
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("UserService is destroy...");
    }
}
